<?php
require_once('Mobile_Detect.php');
require_once('utils.php');
$detect = new Mobile_Detect();

$industries = array();
foreach($lang->home->children() as $element => $value){
	if (strpos(((string)$element), "info") !== false && (string)$element !== 'defaultinfo') {
		array_push($industries, $element);	
	}
}

?>
<!DOCTYPE html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="minimum-scale=1.0, width=device-width, maximum-scale=1.0, user-scalable=no"  />
    <meta name="apple-mobile-web-app-capable" content="yes" />
	<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
    <title><?php echo($lang->home->title) ?></title>
    <meta name="description" content="<?php echo($lang->home->description) ?>" />
    <meta property="fb:app_id" content="<?php echo($lang->home->fbapp_id) ?>" /> 
    <meta property="og:type" content="website" /> 
    <meta property="og:title" content="<?php echo($lang->home->ogtitle) ?>" /> 
   	<meta property="og:image" content="<?php echo(hostname().$lang->home->ogimage) ?>" /> 
	<meta property="og:description" content="<?php echo($lang->home->ogdescription) ?>" /> 
    <meta property="og:url" content="<?php echo(full_url()) ?>">
    
    <link rel="stylesheet" href="css/jquery.mobile.structure-1.0.1.min.css" />
    <link rel="stylesheet" href="css/mobile.css" />
	<link rel="stylesheet" href="css/fonts/fonts.css" />
</head>
<body class="gradient mobile">
    <div data-role="page" id="<?php echo(!isset($_GET['industry']) ? "home" : $_GET['industry']) ?>" class="<?php echo(!isset($_GET['industry']) ? "" : "industry") ?>" data-dom-cache="true" data-ajax="false" data-rel="external">
		<div data-role="content">
			<?php if (!isset($_GET['industry'])) { ?>
			<h1><?php echo($lang->home->header->h1)?></h1>
			<img src="../img/mobile/maptiles.jpg" width="85" height="92" class="map-tiles" />
			<div><?php echo($lang->mobile->intro) ?></div>
			<div class="buttons">
				<a data-role="button" data-transition="reverse slide" class="prev" href="?industry=<?php echo(end($industries)) ?>"  data-url="#<?php echo(end($industries))?>" data-prefetch>prev</a>
				<a data-role="button" data-transition="fade" class="email-link" href="includes/emailDialog.php" data-rel="dialog" data-inline="true"><?php echo($lang->mobile->emailcopy)?></a>
				<a data-role="button" data-transition="slide" class="next" href="?industry=<?php echo(reset($industries)) ?>" data-url="#<?php echo(reset($industries))?>" data-prefetch>next</a>
			</div>
			<div class="swipe"><?php echo($lang->mobile->swipe) ?></div>
			<?php } else { ?>
			<!-- industy code --> 
			<?php 
			$currentPos = intval(array_search($_GET['industry'], $industries));
			$prevIndustry = "";
			$nextIndustry = "";
			$prevHash = "";
			$nextHash = "";
			
			if ($currentPos == 0) 
			{
				$prevIndustry = "mobile.php";
				$nextIndustry = "?industry=".$industries[$currentPos+1];
				$prevHash = "home";
				$nextHash = $industries[$currentPos+1];
			}
			elseif($currentPos == count($industries)-1) // last element
			{
				$prevIndustry = "?industry=" . $industries[$currentPos-1];
				$nextIndustry = "mobile.php";
				$prevHash = $industries[$currentPos-1];
				$nextHash = "home";
			}
			elseif($currentPos > 0) 
			{
				$prevIndustry = "?industry=" . $industries[$currentPos-1];
				$nextIndustry = "?industry=" . $industries[$currentPos+1];
				$prevHash = $industries[$currentPos-1];
				$nextHash = $industries[$currentPos+1];
			}
			?>
			<h1 class="<?php echo($_GET['industry']) ?>"><span><?php echo($lang->home->$_GET['industry']->h2)?></span></h1>
			<img src="../img/mobile/maptiles.jpg" width="85" height="92" class="map-tiles" />
			<div class="copy">
				<?php 
				$search = '##buttons->emaillink##';
				$replacement = '<a href="includes/emailDialog.php" class="email-link" data-rel="dialog" data-inline="true" data-transition="fade">'.$lang->buttons->emaillink.'<span class="link-overlay"></span></a>';
				$generic = str_replace($search, $replacement, $lang->mobile->generic);
				echo('<h2>'.$lang->home->$_GET['industry']->h3.'</h2>'.$lang->mobile->copy->$_GET['industry'].$generic); 
				?>
			</div>
			<div class="cta-buttons">
				<a href="includes/emailDialog.php" class="email-demo ui-btn" data-role="button" data-rel="dialog" data-inline="true" data-transition="fade"><span class="ui-btn-inner"><?php echo($lang->buttons->emaildemo) ?></span></a>
				<a href="iframe.php" class="talk-to-us ui-btn" data-role="button" data-rel="dialog"><span class="ui-btn-inner"><?php echo($lang->buttons->talktous) ?></span></a>
			</div>
			<div class="buttons">
				<a data-role="button" data-transition="reverse slide" class="prev" href="<?php echo($prevIndustry) ?>" data-url="#<?php echo($prevHash)?>" data-prefetch>prev</a>
				<a data-role="button" data-transition="pop" class="take-a-preview" href="take-a-preview.php?industry=<?php echo($_GET['industry']) ?>" data-url="#<?php echo($_GET['industry']) ?>1"><?php echo($lang->mobile->preview)?></a>
				<a data-role="button" data-transition="slide" class="next" href="<?php echo($nextIndustry) ?>" data-url="#<?php echo($nextHash)?>" data-prefetch>next</a>
			</div>
			<?php } ?>
		</div>
		<div data-role="footer" data-position="fixed" id="footer">
			<a data-role="button" data-transition="none" href="./">
				<img src="../img/google-logo.png" alt="<?php echo($lang->home->footer->googlelogoalt) ?>" class="logo" />
			</a>
		</div>
	</div>
	
	<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
    <script>        window.jQuery || document.write('<script src="js/libs/jquery-1.7.1.min.js"><\/script>')</script>
    <script src="//www.google.com/jsapi"></script>
    <script src="js/plugins.js"></script>
    <script src="js/libs/jquery.touchwipe.min.js"></script>
	<script src="js/mobile.js"></script>
	
    <!--<script src="js/libs/jquery.mobile-1.0.1.min.js"></script>-->
        
    <?php include_once($_SERVER["DOCUMENT_ROOT"].'/includes/ga.php') ?>
	<script src="js/analytics.js"></script>
</body>
</html>
